# Contributor: Damian Kurek <starfire24680@gmail.com>
# Maintainer: Damian Kurek <starfire24680@gmail.com>
pkgname=kodi-game-libretro-beetle-lynx
pkgver=1.24.0.16
_realname=Matrix
pkgrel=1
pkgdesc="Beetle-Lynx for Kodi"
options="!check" # no test suite
url="https://github.com/kodi-game/game.libretro.beetle-lynx"
arch="x86 x86_64 aarch64 armv7" # kodi
license="GPL-2.0-only AND Zlib"
makedepends="cmake kodi-dev"
depends="kodi-game-libretro libretro-beetle-lynx"
source="$pkgname-$pkgver-$_realname.tar.gz::https://github.com/kodi-game/game.libretro.beetle-lynx/archive/$pkgver-$_realname.tar.gz"
builddir="$srcdir/game.libretro.beetle-lynx-$pkgver-$_realname"

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake/kodi
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
	rm -r "$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-lynx/resources/icon.png \
		"$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-lynx/resources/screenshot* \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.beetle-lynx/game.libretro.beetle-lynx.so
	ln -s /usr/lib/libretro/mednafen_lynx_libretro.so \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.beetle-lynx/game.libretro.beetle-lynx.so
	sed -i '/<assets>/,/<\/assets>/d' "$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-lynx/addon.xml
}

sha512sums="38906104c3ff76c9161b684ef7708e05905ffdd9841027cfaac7f9a0059783d26dccdf321cd223f98ec480978823c888fe04cae9b9e6a9cb132631b1e2a2413c  kodi-game-libretro-beetle-lynx-1.24.0.16-Matrix.tar.gz"
